#include <mono/common/date_time.h>
#include <mono/common/timestamp.h>
#include <mono/common/date_time_formatter.h>
#include <mono/common/date_time_parser.h>
#include <mono/common/date_time_format.h>
#include <mono/common/local_date_time.h>
#include <iostream>
using namespace mono;

int main()
{
	DateTime dt;
	Timestamp ts;
	LocalDateTime ldt;
	std::cout<<"GMT"<<std::endl;
	std::cout<<DateTimeFormatter::format(dt, DateTimeFormat::ISO8601_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(dt, DateTimeFormat::ISO8601_FRAC_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(dt, DateTimeFormat::RFC822_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(dt, DateTimeFormat::RFC1123_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(dt, DateTimeFormat::HTTP_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(dt, DateTimeFormat::RFC850_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(dt, DateTimeFormat::RFC1036_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(dt, DateTimeFormat::ASCTIME_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(dt, DateTimeFormat::SORTABLE_FORMAT)<<std::endl;
	std::cout<<"ts"<<std::endl;
	std::cout<<DateTimeFormatter::format(ts, DateTimeFormat::ISO8601_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(ts, DateTimeFormat::ISO8601_FRAC_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(ts, DateTimeFormat::RFC822_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(ts, DateTimeFormat::RFC1123_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(ts, DateTimeFormat::HTTP_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(ts, DateTimeFormat::RFC850_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(ts, DateTimeFormat::RFC1036_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(ts, DateTimeFormat::ASCTIME_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(ts, DateTimeFormat::SORTABLE_FORMAT)<<std::endl;
	std::cout<<"Local"<<std::endl;
	std::cout<<DateTimeFormatter::format(ldt, DateTimeFormat::ISO8601_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(ldt, DateTimeFormat::ISO8601_FRAC_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(ldt, DateTimeFormat::RFC822_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(ldt, DateTimeFormat::RFC1123_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(ldt, DateTimeFormat::HTTP_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(ldt, DateTimeFormat::RFC850_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(ldt, DateTimeFormat::RFC1036_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(ldt, DateTimeFormat::ASCTIME_FORMAT)<<std::endl;
	std::cout<<DateTimeFormatter::format(ldt, DateTimeFormat::SORTABLE_FORMAT)<<std::endl;

	std::string tmp = DateTimeFormatter::format(dt, DateTimeFormat::ISO8601_FORMAT);
	DateTime rdt;
	int tz;
	bool r= DateTimeParser::parse(DateTimeFormat::ISO8601_FORMAT, tmp, rdt, tz);
	std::string tmps = DateTimeFormatter::format(dt, DateTimeFormat::ISO8601_FORMAT);
	if(!r ) {
		std::cout<<"[error] parser error"<<std::endl;
	} else if (tmp != tmps){
		std::cout<<"[error] reformat error"<<std::endl;
	} else {
		std::cout<<"pass ok"<<tz<<std::endl;
	}

	std::string httpdt = DateTimeFormatter::format(dt, DateTimeFormat::HTTP_FORMAT);
	tmps = DateTimeFormatter::format(dt, DateTimeFormat::HTTP_FORMAT);
	r= DateTimeParser::parse(DateTimeFormat::HTTP_FORMAT, httpdt, rdt, tz);
	if(!r ) {
		std::cout<<"[error] parser error"<<std::endl;
	} else if (httpdt != tmps){
		std::cout<<"[error] reformat error"<<std::endl;
	} else {
		std::cout<<"http format pass ok"<<tz<<std::endl;
	}

	LocalDateTime httplocal(rdt);
	std::cout<<DateTimeFormatter::format(httplocal, DateTimeFormat::HTTP_FORMAT)<<std::endl;

	return 0;
}